<table class="table">
    <tr>
        <th style="width: 100px; ">{{ _("Date") }}</th>
        <th style="width: 125px; text-align: right; " >{{ _("Amount") }}</th>
        <th>{{ _("Party") }}</th>
        <th>{{ _("Reference") }}</th>
        <th>{{ _("Action") }}</th>
    </tr>
    {% for transaction in transactions %}
    <tr id="row-transaction-{{ transaction.txid }}">
        <td>{{ frappe.utils.get_datetime(transaction.date).strftime("%d.%m.%Y") }}</td>
        <td style="text-align: right; " >
            
            {% if transaction.credit_debit == "DBIT" %}
                <span class="octicon octicon-repo-pull"></span>
            {% else %}
                <span class="octicon octicon-repo-push"></span>
            {% endif %}
            {{ transaction.currency }} {{ "{:,.2f}".format(transaction.amount or 0).replace(",", "`") }}
        </td>
        <td>{{ transaction.party_name }}{% if transaction.party_address %}<br> {{ transaction.party_address }}{% endif %}</td>
        <td>{{ transaction.transaction_reference }}</td>
        <td>
          {% if transaction.credit_debit == "DBIT" %}
            <!-- Supplier -->
            {% if transaction.amount == transaction.matched_amount %}
             {% if transaction.invoice_matches %}
               <button type="submit" class="btn btn-xs btn-primary" id="btn-quick-pinv-{{ transaction.txid }}"><i class="fa fa-arrow-right"></i></button>
             {% endif %}
             {% if transaction.expense_matches %}
               <button type="submit" class="btn btn-xs btn-primary" id="btn-quick-exp-{{ transaction.txid }}"><i class="fa fa-arrow-right"></i></button>
             {% endif %}
            {% elif transaction.pattern %}
               <button type="submit" class="btn btn-xs btn-primary" id="btn-quick-pattern-pay-{{ transaction.txid }}"><i class="fa fa-magic"></i></button>
            {% endif %}
            {% if transaction.invoice_matches %}
             <button type="submit" class="btn btn-xs btn-success" id="btn-close-pinv-{{ transaction.txid }}">{{ _("Purchase Invoice") }}</button>
            {% endif %}
            {% if transaction.party_match %}
             <button type="submit" class="btn btn-xs btn-warning" id="btn-close-supplier-{{ transaction.txid }}">{{ _("Supplier") }}</button>
            {% endif %}
            {% if transaction.expense_matches %}
             <button type="submit" class="btn btn-xs btn-success" id="btn-close-exp-{{ transaction.txid }}">{{ _("Expense Claim") }}</button>
            {% endif %}
            {% if transaction.employee_match %}
             <button type="submit" class="btn btn-xs btn-warning" id="btn-close-employee-{{ transaction.txid }}">{{ _("Employee") }}</button>
            {% endif %}
            <button type="submit" class="btn btn-xs btn-default" id="btn-close-payable-{{ transaction.txid }}">{{ _("Payables") }}</button>
          {% else %}
            <!-- Customer -->
            {% if transaction.amount == transaction.matched_amount %}
             <button type="submit" class="btn btn-xs btn-primary" id="btn-quick-sinv-{{ transaction.txid }}"><i class="fa fa-arrow-right"></i></button>
            {% elif transaction.pattern %}
               <button type="submit" class="btn btn-xs btn-primary" id="btn-quick-pattern-rec-{{ transaction.txid }}"><i class="fa fa-magic"></i></button>
            {% endif %}
            {% if transaction.invoice_matches %}
             <button type="submit" class="btn btn-xs btn-success" id="btn-close-sinv-{{ transaction.txid }}">{{ _("Sales Invoice") }}</button>
            {% endif %}
            {% if transaction.party_match %}
             <button type="submit" class="btn btn-xs btn-warning" id="btn-close-customer-{{ transaction.txid }}">{{ _("Customer") }}</button>
            {% endif %}
            <button type="submit" class="btn btn-xs btn-default" id="btn-close-receivable-{{ transaction.txid }}">{{ _("Receivables") }}</button>
          {% endif %}
          <button type="submit" class="btn btn-xs btn-default" id="btn-close-intermediate-{{ transaction.txid }}">{{ _("Intermediate") }}</button>
        </td>
    </tr>
    {% endfor %}
</table>
